import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { MyValidators } from '../myValidators';

@Component({
  selector: 'app-validators',
  templateUrl: './validators.component.html',
  styles: [
  ]
})
export class ValidatorsComponent {
  contactForm: FormGroup = new FormGroup({
    name: new FormControl("1", [
      Validators.required,
      Validators.minLength(2),
      MyValidators.cannotContainSpace
    ], MyValidators.shouldBeUnique )
  })
  onSubmit () {
    console.log(this.contactForm.valid)
  }
  get name () {
    return this.contactForm.get('name')!
  }
}
